package eabnp.web.eflow;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;

import eabnp.eflow.client.impl.local.EFlowClientRmi;
import eabnp.eflow.client.impl.local.IEFlowClientRmi;
import eabnp.service.ServiceManager;
import eabnp.service.startup.servlet.AbsStartUpServlet;

public class StartServiceServlet extends AbsStartUpServlet {

	private static final long serialVersionUID = 1L;

	public void init() throws ServletException {
		try {
			Context namingContext = new InitialContext();
			IEFlowClientRmi EFlowRmi = new EFlowClientRmi("EFLOW_RMI"); 
			LocateRegistry.createRegistry(8099);  
			namingContext.rebind("rmi://127.0.0.1:8099/eflowrmi", EFlowRmi); 
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		} 
		String path = getInitParameter("EABnPPath");
		ServiceManager.start(path);
	}

}
